var disco;
(function (disco) {
    (function (web) {
        var Requests = (function () {
            function Requests() {
            }
            Requests.loadOntologyMetadata = function (url, success, error) {
                if (typeof error === "undefined") { error = null; }
                OData.read(url, success, error, OData.metadataHandler);
            };

            Requests.loadOntologyContent = function (url, success, error) {
                if (typeof error === "undefined") { error = null; }
                jQuery.ajax({
                    headers: { Accept: "application/json;odata=fullmetadata" },
                    url: url,
                    success: success,
                    error: function (a, b, err) {
                        if (error)
                            error(err);
                    },
                    cache: false
                });
            };

            Requests.addEntity = function (entitySetUrl, propertyValues, success, error) {
                if (typeof error === "undefined") { error = null; }
                jQuery.ajax({
                    headers: { Accept: "application/json;odata=fullmetadata" },
                    url: entitySetUrl,
                    type: "POST",
                    data: propertyValues,
                    success: success,
                    error: function (a, b, err) {
                        if (error)
                            error(err);
                    },
                    cache: false
                });
            };

            Requests.removeEntity = function (entityUrl, success, error) {
                if (typeof error === "undefined") { error = null; }
                jQuery.ajax({
                    url: entityUrl,
                    type: "DELETE",
                    success: success,
                    error: function (a, b, err) {
                        if (error)
                            error(err);
                    },
                    cache: false
                });
            };

            Requests.addEntityConnection = function (entityUrl, propertyUrl, valueUrl, success, error) {
                if (typeof error === "undefined") { error = null; }
                jQuery.ajax({
                    url: entityUrl + '/$links/' + propertyUrl,
                    type: "POST",
                    data: JSON.stringify({ url: valueUrl }),
                    processData: false,
                    contentType: 'application/json; charset=UTF-8',
                    success: success,
                    error: function (x, y, e) {
                        if (error)
                            error(e);
                    }
                });
            };

            Requests.removeEntityConnection = function (entityUrl, propertyUrlWithKey, success, error) {
                if (typeof error === "undefined") { error = null; }
                jQuery.ajax({
                    url: entityUrl + '/$links/' + propertyUrlWithKey,
                    type: "DELETE",
                    success: success,
                    error: function (x, y, e) {
                        if (error)
                            error(e);
                    }
                });
            };
            return Requests;
        })();
        web.Requests = Requests;
    })(disco.web || (disco.web = {}));
    var web = disco.web;
})(disco || (disco = {}));
